home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
3_14.lha
/
3_14
/
3_14c2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
900b
|
49 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <string.h>
har *get_funcdefn()
const chunksize = 128;
int slen = chunksize;
char *s = new char[slen];
char *sp = s;
char ch;
for (;;) // loop until end of definition
{
if (!cin.get(ch)) // oops, EOF
{
curr_tok = END;
return 0;
}
if (ch == LB) // another oops
{
error("no recursively defined functions");
curr_tok = PRINT;
return 0;
}
if (ch == RB) // found end
{
*sp = '\0';
(void) get_token(); // skip RB
return s;
}
*sp++ = ch;
if (sp - s >= slen) // check for buffer end
{ // and reallocate space
int oslen = slen;
slen += chunksize;
char *t = new char[slen];
memcpy(t, s, oslen);
delete [oslen] s;
s = t;
sp = s + oslen;
}
}